package org.example.aaaatest.a1;

import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

/**
 * @description:
 * @author: wangbaogui
 * @create: 2025/4/7 17:44
 **/
public class A1 {
    private static final String dou_di = "unknown";
    public static void main(String[] args) throws ParseException {
        String adCode = "810101";
        String areaCode = "";
        if (StringUtils.isNotBlank(adCode) && adCode.length() >= 2){

            /*
 // 从 JSONObject 中获取 additionalServices 对应的 JSONArray
        JSONArray additionalServices = jsonObject.getJSONArray("additionalServices");

        // 可以对 JSONArray 进行进一步操作，例如遍历
        for (int i = 0; i < additionalServices.length(); i++) {
            JSONObject service = additionalServices.getJSONObject(i);
            String code = service.getString("code");
            int count = service.getInt("count");
            if ("BBS".equals(code)) {
                System.out.println("Code: " + code + ", Count: " + count);
            }
            if ("MAG".equals(code)) {
                System.out.println("Code: " + code + ", Count: " + count);
            }
             */
            if (adCode.length() > 6) {
                //国际订单
                areaCode = adCode.substring(0, 3);
                System.out.println("areaCode = " + areaCode);
                return;
            } else {
                //国内
                areaCode = adCode.substring(0, 2);
            }
        }
        // adCode前两位
        String finalAreaCode = Lists.newArrayList("81", "82").contains(areaCode) ? areaCode : "10";
        System.out.println("finalAreaCode = " + finalAreaCode);


        String timeStr = "2025-03-25 16:25:59";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = sdf.parse(timeStr);
        long millis = date.getTime();
        System.out.println(millis
         );

        /*
        JSONinecq
         */

        /*
        CommonResponseDTO<MerchantInfoDTO> response = queryMerchantInfo(param);
if (response.getStatus() == 0) {
    List<MerchantInfoDTO> merchants = response.getData();
    if (merchants != null && !merchants.isEmpty()) {
        for (MerchantInfoDTO dto : merchants) {
            System.out.println("Peer No: " + dto.getPeerNo());
        }
    } else {。问世间情为何物 只叫人生死相依
        System.out.println("No data found.");
    }
} else {
    System.out.println("Failed: " + response.getMessage());
}

         */
        long millis1 = 1744098675376L;
        Date date1 = new Date(millis1);
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String timeStr1 = sdf1.format(date1);
        System.out.println("ddddddddxsď11sssss"+timeStr1);
        // 示例：1 / 7.32 = 0.1366（保留6位小数）
        /*
        、安安心心国gui jeguije  bbaoca

         */
        BigDecimal usdToCnyRate = new BigDecimal("7.32");
        BigDecimal cnyToUsdRate = BigDecimal.ONE.divide(usdToCnyRate, 2, RoundingMode.HALF_UP);
        System.out.println("cnyToUsdRate11111111111 = " + cnyToUsdRate);


        // 创建ZonedDateTime对象
        ZonedDateTime zonedDateTime = ZonedDateTime.parse("2025-04-08T15:02:06.189+09:00[Asia/Tokyo]");

        // 转换为Instant对象
        Instant instant = zonedDateTime.toInstant();
        Date from = Date.from(instant);
        System.out.println("from = " + from);

        ZonedDateTime truncatedDateTime = zonedDateTime.truncatedTo(ChronoUnit.MINUTES);


        // 转换为 Date 对象
        Date date11 = Date.from(truncatedDateTime.toInstant());
        System.out.println("Date 对象（UTC 时间）: " + date11);


        // 输出结果
        System.out.println("ZonedDateTime11111: " + zonedDateTime);
        System.out.println("Instant1111111: " + instant);

        long milliseconds = zonedDateTime.toInstant().toEpochMilli();
        System.out.println("milliseconds = " + milliseconds);

        // 转换为Date对象
        Date date111 = new Date(milliseconds);
        System.out.println("date11 = " + date111);


        // 转换为Date对象（不涉及时区转换）
        System.out.println("=======================");
        try {
            throw new Exception("异常测试");
        } catch (Exception e) {
            e.printStackTrace();  //异常测试输出
            System.out.println("e = " + e.getMessage());
            System.out.printf("");
        }
        System.out.println("=======================");



    }

}
